package com.yaozheng.vocationaltraining.fragment;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.activity.CourseCatalogActivity_;
import com.yaozheng.vocationaltraining.activity.HomeActivity;
import com.yaozheng.vocationaltraining.activity.HomeActivity_;
import com.yaozheng.vocationaltraining.utils.Constants;

/**
 * 学习Fragment
 *
 * @author Administrator
 *         *
 */
@EFragment(R.layout.fragment_learn)
public class LearnMenuFragment extends BaseFragment {
    private HomeActivity homeActivity;
    @ViewById
    TextView headTitleText;

    public HomeActivity getHomeActivity() {
        return (HomeActivity) getActivity();
    }

    @AfterViews
    public void initView() {
        headTitleText.setText("学习");
    }

    /**
     * 进入列表
     */
    public void enterLearnList() {
        try {
//			getBaseActivity().setIntentInt("menuType",
//					Integer.parseInt(view.getTag().toString()));
            getBaseActivity().setIntentInt("menuType",
                    2);

            getHomeActivity().openLearnListFragment();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 品牌点击
     */
    @Click({R.id.learnBrandsTextView})
    public void learnBrandsClick() {
        getBaseActivity().setIntentString("learnListTitle", getString(R.string.learnBrandsStr));
        getBaseActivity().setIntentInt("selectLearnIndex", 0);
        enterLearnList();
    }

    /**
     * 商品点击
     */
    @Click({R.id.learnCommodityTextView})
    public void learnCommodityClick() {
        getBaseActivity().setIntentString("learnListTitle", getString(R.string.learnCommodityStr));
        getBaseActivity().setIntentInt("selectLearnIndex", 1);
        enterLearnList();
    }

    /**
     * 销售点击
     */
    @Click({R.id.learnSalesLayout})
    public void learnSalesClick() {
        getBaseActivity().setIntentString("learnListTitle", getString(R.string.learnSalesStr));
        getBaseActivity().setIntentInt("selectLearnIndex", 2);
        enterLearnList();
    }

    /**
     * 服务点击
     */
    @Click({R.id.learnServiceTextView})
    public void learnServiceClick() {
        getBaseActivity().setIntentString("learnListTitle", getString(R.string.learnCommodityStr));
        getBaseActivity().setIntentInt("selectLearnIndex", 3);
        enterLearnList();
    }

    /**
     * 技术点击
     */
    @Click({R.id.learnTechnologyTextView})
    public void learnTechnologyClick() {
        getBaseActivity().setIntentString("learnListTitle", getString(R.string.learnCommodityStr));
        getBaseActivity().setIntentInt("selectLearnIndex", 4);
        enterLearnList();
    }

    /**
     * 岗位点击
     */
    @Click({R.id.learnPostTextView})
    public void learnPostClick() {
        getBaseActivity().setIntentString("learnListTitle", getString(R.string.learnCommodityStr));
        getBaseActivity().setIntentInt("selectLearnIndex", 5);
        enterLearnList();
    }


    /**
     * 离线课堂
     */
    @Click({R.id.offlineClassroomLayout})
    public void enterOfflineLearn() {

        Intent intent = new Intent();
        intent.setClassName(getContext(),
                Constants.COURSE_CATALOG_ACTIVITY_CLASS_NAME);
        intent.putExtra("menuType", 4);
        intent.putExtra("title", "离线课堂");
        getContext().startActivity(intent);
    }

}
